package com.ddd.demo.listviewdemo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * Created by doushuqi on 15/4/29.
 */
public class DataBaseHelper extends SQLiteOpenHelper {
    private static final String TAG = "DateBaseHelper";

    private DataBaseHelper(Context context) {
        super(context, "list_data", null, 1);
    }

    private static DataBaseHelper mDataBaseHelper;

    public static DataBaseHelper getInstance(Context context) {
        if (mDataBaseHelper == null) {
            mDataBaseHelper = new DataBaseHelper(context);
        }

        return mDataBaseHelper;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.e(TAG, "DataBase Create.");
        db.execSQL("CREATE TABLE IF NOT EXISTS person" +
                "(_id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR, age INTEGER, info TEXT)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
